package com.wuhan.template.module.home.fragment;

import android.os.Bundle;
import android.support.annotation.NonNull;
import android.widget.TextView;

import com.google.gson.Gson;
import com.wuhan.template.R;
import com.wuhan.template.base.BaseFragment;
import com.wuhan.template.constant.Urls;
import com.wuhan.template.module.home.entity.DianShiZhuTi;
import com.wuhan.template.utils.EventMessage;
import com.wuhan.template.utils.OkHttpUtils;

import butterknife.BindView;

/**
 * Created by Administrator on 2016/5/12 0012.
 */
public class JIMuZhuTiFragment extends BaseFragment{

    @BindView(R.id.jiemudan_zhuti)
    protected TextView title;
    @BindView(R.id.zhuti_content)
    protected TextView content;

    private String dianshiId;

    @Override
    protected int getLayoutId() {
        return R.layout.fragment_jiemu_zhuti;
    }

    public JIMuZhuTiFragment() {
    }

    @Override
    protected void initViews() {
        super.initViews();
    }

    @Override
    protected void loadData() {
        OkHttpUtils.get(Urls.DIANSHIZHUTI+"&channel_id=" + dianshiId,null);

    }
    @Override
    protected void postEventResult(@NonNull EventMessage message) {
        if(message.type.equals(Urls.DIANSHIZHUTI+"&channel_id=" + dianshiId)){
            Gson gson = new Gson();
            DianShiZhuTi dianShiZhuTi = gson.fromJson(message.result, DianShiZhuTi.class);
            title.setText(dianShiZhuTi.getInfo().getTitle());
            content.setText(dianShiZhuTi.getInfo().getBrief());

        }
    }

    @Override
    protected void getReqParams(Bundle bundle) {
         dianshiId = bundle.getString("id");
    }
}
